HISTORY

OAK

  • 1990
  • Platform Independent
  • Not Popular
  • Desktop Application

JAVA

  • FOSS : FREE AND OPEN SOURCE
  • Java is an Object-Oriented programming language
  • Most of it is free and open source!
  • It is developed in the early 1990s, by James Gosling of Sun Microsystems
  • It allows development of software applications.
  • It is amongst the preferred choice for developing internet-based applications
  • Notes

    • Partially Object Oriented
    • Can be changed to fully OOP by removing premitive datatype
    • Memory delocation Memory is auto delocated by Garbage collector
    • Garbage is a demon thread [low risk]
    • No pointers 🍺
    • Dynamic
    • Strongly typed
      • Java is Robust
        • Because it is highly supported language.
        • It is portable across many Operating systems.
        • Java also has feature of Automatic memory management and garbage collection.
        • Strong type checking mechanism of Java also helps in making Java Robust. Bugs, especially system crashing bugs, are very rare in Java.
    • Easily debuggale
    • WORA: Write once, run anywhere.

      • We run Byte code while run time.
      • JVM has multiple events

        • JVM loads CLASS LOADER

          Security

        • BYTE CODE VERIFIER

          • Checks if byte code has been alterd by third party, the unique signature will be removed.
          • If so, it throws errors and doesn't allow to run, even after undoing the changes.

        • JIT compiler [Just In Time]

          • At the time of conversion, it checks if the code is repeated and creates block of repeated codes, so that interpreter won't interprete repeated code. Thus, this JIT increases performace of application.
        • Interprator

          • Convert byte code to machine code at runtime.
          • Eg: interpreter on windows converts machine code of windows
        • Execution
          • Here Machine code gets executed.
      • Multithreaded
        • Multiple procceses applications can be developed by JAVA.
      • Dynamic
        • Changes done during runtime

Key 💡

The main advantage of JVM is that JVM makes Java platform-independent by executing bytecodes.

Sample

Image

  • Good Practise to follow convention
  • Class Name shound be Noun
    • Makes us easy to
      • Identify
      • understand
      • Read
  • Always Start class name with Captial Letter.

Key 💡

JVM enters into the program by main method So the main method should always be public

Min method always be static

In Static object is not required

Member can access only through object method. So instance doesn't requied to have object to access the Main method is accesd by JVM. If the main method is not a static, then JVM won't able to access the main method. Since object creation is not a part of the JVM, JVM doesn't create object to access the main method. So, the main method should always be public static.

helloWorld

  1. Every class has a constructor whether it’s a normal class or a abstract class.
  2. Constructors are not methods and they don’t have any return type.
  3. Constructor name should match with class name .
  4. Constructor can use any access specifier, they can be declared as private also. Private constructors are possible in java but there scope is within the class only.
  5. Like constructors method can also have name same as class name, but still they have return type, though which we can identify them that they are methods not constructors.
  6. If you don’t implement any constructor within the class, compiler will do it for.
  7. this() and super() should be the first statement in the constructor code. If you don’t mention them, compiler does it for you accordingly.
  8. Constructor overloading is possible but overriding is not possible. Which means we can have overloaded constructor in our class but we can’t override a constructor.
  9. Constructors can not be inherited.
  10. If Super class doesn’t have a no-arg(default) constructor then compiler would not insert a default constructor in child class as it does in normal scenario.
  11. Interfaces do not have constructors.
  12. Abstract class can have constructor and it gets invoked when a class, which implements interface, is instantiated. (i.e. object creation of concrete class).
  13. A constructor can also invoke another constructor of the same class – By using this(). If you want to invoke a parameterized constructor then do it like this: this(parameter list).

Day 2

Happy Coding : @Sai Kishore